#include <iostream>
#include <unistd.h>

using namespace std;

int main()
{
    int pipefd[2];
    int ret = pipe(pipefd);
    ret = fork();
    if(ret < 0){
        return -1;
    }
    if(ret > 0){
        char buffer[1024] = "hello child";
       ret =  write(pipefd[1], buffer, 1024);
       cout<<"i am father, i write"<<ret<<"bit"<<endl;
    }else{
        sleep(3);
        char buffer[1024] = {'\0'};
        read(pipefd[0], buffer, 1023);
        cout<<"child read "<<buffer<<endl;
        cout<<11111;
    }
    return 0;
}
